package com.fansea.util;

public class WeatherUtil {
    public static String getWeather(String area){
        String appId ="64367285";
        String appSecret="e0Xoew3B";
        String weather = HttpRequestUtil.doGet("https://v0.yiketianqi.com/api?version=v61&appid="+appId+"&appsecret="+appSecret+"&city="+area);
        //获取气温，天气状况
        String type = JSONStringHandleUtil.getStats(weather, "wea");
        String low = JSONStringHandleUtil.getStats(weather, "tem2");
        String high = JSONStringHandleUtil.getStats(weather, "tem1");
        String tip = JSONStringHandleUtil.getStats(weather, "alarm");
        String alarm_content;
        if (tip !=null){
            alarm_content = JSONStringHandleUtil.getStats(tip, "alarm_content");
        }else {
            alarm_content="暂无预警通知！";
        }
        return "天气："+type+"\n最低气温："+low+"\n最高气温："+high+"\n预警："+alarm_content;
    }
}
